package com.godofgamblers.hotelmanagementsystem.mapper;

import com.godofgamblers.hotelmanagementsystem.pojo.Order;
import com.godofgamblers.hotelmanagementsystem.pojo.Order_item;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.*;

/**
 * @author Haonan
 * @date 2019/10/22 - 17:42
 */
@Repository
@Component
public interface UserCenterMapper {
    // 给用户中心用的Mapper查订单项
    @Select("SELECT order_item.* FROM order_item LEFT JOIN `order` ON order_item.order_id = `order`.order_id WHERE `order`.user_id = #{user_id} AND order_item_state = 0")
    public List<Order_item> findUnpaidOrderItem(int user_id);

    // 给用户中心查订单
    @Select("SELECT * FROM `order` WHERE user_id = #{user_id} AND order_state = 0;")
    public List<Order> findUnpaidOrder(int user_id);

    @Select("SELECT order_item.* FROM order_item LEFT JOIN `order` ON order_item.order_id = `order`.order_id WHERE `order`.user_id = #{user_id} AND order_item_state = 1")
    public List<Order_item> findUnusedOrderItem(int user_id);

    @Select("SELECT order_item.* FROM order_item LEFT JOIN `order` ON order_item.order_id = `order`.order_id WHERE `order`.user_id = #{user_id} AND order_item_state = 5")
    public List<Order_item> findCompleteOrderItem(int user_id);
}